<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>VueJs指令：v-for</title>
</head>
<body>

<div id="app">
    <h3>普通属性</h3>
    <p>{{title}}</p>
    <p>{{age}}</p>
    <h3>对象属性</h3>
    <p>{{user.name}}==={{user.age}}</p>
    <h3>数组属性</h3>
    <p v-for="user in friends">{{user}}</p>
    <h3>数组对象属性</h3>
    <p v-for="user in users">{{user.name}}---{{user.age}} -- {{user.male}}</p>
    <h3>数组对象属性</h3>
    <p v-for="(user,index) in users">
        {{index+1}}=={{user.name}}---{{user.age}} -- {{user.male}}
        <button @click="addage(index)">年龄增加</button>
    </p>

</div>

<script src="js/vue.min.js"></script>

<script>
    var vue = new Vue({
        el:"#app",
        data:{
            title:"我是一个帅哥!",
            age:20,
            user:{
               name:"zhangsan",
               age:20,
               male:1
            },
            friends:["xiaohong","xiaoming","xiaozhang"],
            users:[
                {
                    name:"zhangsan",
                    age:20,
                    male:1
                },{
                    name:"李四",
                    age:20,
                    male:1
                },
            ]

        },
        methods:{
            addage:function(index){
                this.users[index].age ++;
            }
        }
    })
</script>
</body>
</html>